#!/bin/bash
set -e
MAIN_BRANCH=${1:-'master'}

#PARAM1=$0
#if [[ -n "${PARAM1}" ]]; then
cd /mnt/repo/wowplan/ruoyi
git checkout ${MAIN_BRANCH}
git pull
mvn clean install -Dmaven.test.skip=true -f pom.xml
#fi

SOURCE_ROOT_PATH=/mnt/repo/wowplan/ruoyi
TARGET_ROOT_PATH=/mnt/app/wowplan
################################################################
APP_PATH=wowplan
JAR_NAME=${APP_PATH}.jar
JAR_SOURCE_PATH=${SOURCE_ROOT_PATH}/target/${JAR_NAME}
JAR_TARGET_PATH=${TARGET_ROOT_PATH}/${JAR_NAME}
manager_path=$(dirname ${JAR_TARGET_PATH})
if [ ! -d ${manager_path} ] ; then
    mkdir -p ${manager_path}
fi

cp ${JAR_SOURCE_PATH} ${JAR_TARGET_PATH}
echo ${JAR_TARGET_PATH}
